﻿//using ARC.Common.Help;
//using Core.FrameWork.Commons.ApiResult;
//using Core.FrameWork.Commons.ORM.Abstraction;
//using Core.FrameWork.Commons.Pages;
//using Core.FrameWork.Models.Models;
//using Core.FrameWork.Models.Models.System;
//using Core.Web.Api.Application.Services.SysBaseTree.Abstraction;
//using Microsoft.AspNetCore.Mvc;
//using Microsoft.EntityFrameworkCore;
//using Newtonsoft.Json.Linq;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Linq.Expressions;
//using System.Threading.Tasks;

//namespace Core.Web.Admin.Controllers.Sys
//{
//    public class BaseTreeController : BaseController
//    {
//        private readonly ISysBaseTreeService _sysBaseTreeService;
//        public BaseTreeController(IDbContextCore dbContextCore, ISysBaseTreeService sysBaseTreeService) : base(dbContextCore)
//        {
//            _sysBaseTreeService = sysBaseTreeService;
//        }
//        public IActionResult Index()
//        {
//            return View();
//        }
//        public async Task<string> QueryTreeByPid(Guid id = default(Guid), int flag = 0)
//        {
//            JArray listArray = new JArray();
//            var list = await _sysBaseTreeService.QueryTreeByPid(id, flag);

//            if (flag == 1 && id == Guid.Empty)
//            {
//                JObject obj = new JObject
//                {
//                    ["id"] = 0,
//                    ["pId"] = 0,
//                    ["name"] = "根节点",
//                    ["isParent"] = false,
//                    ["open"] = true
//                };
//                listArray.Add(obj);
//            }
//            foreach (var item in list)
//            {
//                JObject obj = new JObject
//                {
//                    ["id"] = item.Id,
//                    ["pId"] = item.PId,
//                    ["name"] = item.TreeName,
//                    ["open"] = true
//                };
//                listArray.Add(obj);
//            }
//            return listArray.ToString();
//        }
//        [HttpPost]
//        public CommonResult GetList(int pageIndex = 1, int pageSize = 10, Guid pId = default(Guid))
//        {
//            PagerInfo pagerInfo = new PagerInfo()
//            {
//                CurrenetPageIndex = pageIndex,
//                PageSize = pageSize
//            };
//            // var list = _sysBaseTreeService.GetPageList(s => s.PId == pId, pagerInfo, new bool[] { true, false }, new Expression<Func<FrameWork.Models.Models.System.SysBaseTree, object>>[] { s => s.Sort, s => s.CreateTime }).Select(s=> new { ctime= s.CreateTime.ToString(),Sort=s.Sort} ).ToList();

//            // return ApiRespHelp.getApiDataListByPage<Core.FrameWork.Models.Models.System.SysBaseTree>(list, pagerInfo.RecordCount, pageIndex, pageSize);
//return  null;
//        }
       
//    }
//}
